<template>
	<div class="index">
  <div class="index-content">
    <div>引导页</div>
		<div class="enter-all hospital-enter"> SNS入口：<span class="enter-icon-yy"></span></div>
    <div class="list">
    	<ul>
    		<li class="item" v-for="(yyitem, yyindex) in snsDate.list" :key="yyindex" @click="gotoSite(yyitem)" :title="yyitem.siteName">
    			<div class="item-text" >{{yyitem.siteName}}</div>
    		</li>
    	</ul>
    </div>
    <div class="enter-all hospital-enter">洗涤入口：<span class="enter-icon-yy"></span></div>
    <div class="list">
    	<ul>
    		<li class="item" v-for="(xditem, xdindex) in xdDate.list" :key="xdindex" @click="gotoSite(xditem)" :title="xditem.siteName">
    			<div class="item-text">{{xditem.siteName}}</div>
    		</li>
    	</ul>
    </div>	
		</div>
	</div>
</template>


<script>
import API from "./api";
import { setCookieObj, getCookieObj } from "@/libs/util";
import mixinSite from "@/mixin/site-mixin";
export default {
  name: "index",
  mixins: [mixinSite],
  data() {
    return {
      snsDate: {
        list: [
          {
            siteName: "SNS",
            logo: "http://hqn.fun:9999/cqykdxfsetyy-logo.png",
            api: "http://211.100.28.180/BEEWebAPIYWChCMU/api/",
            login: "sns-login",
            type: "sns",
            name: "sns"
          },
          {
            siteName: "PositiveSingles",
            logo: "http://hqn.fun:9999/cqykdxfsetyy-logo.png",
            api: "http://211.100.28.180/BEEWebAPIYWChCMU/api/",
            login: "ps-login",
            type: "sns",
            name: "ps"
          },
          {
            siteName: "MillionaireMatch",
            logo: "http://hqn.fun:9999/cqykdxfsetyy-logo.png",
            api: "http://211.100.28.180/BEEWebAPIYWChCMU/api/",
            login: "mm-login",
            type: "sns",
            name: "mm"
          }
        ]
      },
      xdDate: {
        list: [
          {
            siteName: "洗涤系统",
            logo: "http://hqn.fun:9999/cqykdxfsetyy-logo.png",
            api: "http://211.100.28.180/BEEWebAPIYWChCMU/api/",
            login: "xd-login",
            type: "xd",
            name: "xd"
          }
        ]
      }
    };
  },

  created() {
    let obj = this.getCurrentSiteConfig();
    let name = this.$route.query.from;
    if (name !== "login" && obj && obj.login && obj.type) {
      this.gotoSite(obj);
    }
  },

  methods: {
    gotoSite(obj) {
      this.saveSiteInfo(obj);
      this.$router.push({
        name: obj.login
      });
    },

    saveSiteInfo(data) {
      let obj = this.getCurrentSiteConfig();
      let config = this.configSite(data.type, data.login, data.name);
      if (obj) {
        obj.name = config.name;
        obj.login = config.login;
        obj.type = config.type;
        obj.apiURL = config.apiURL;
        obj.apiType = config.apiType;
      } else {
        obj = {
          name: name,
          login: config.login,
          type: config.type,
          apiURL: config.apiURL,
          apiType: config.apiType
        };
      }
      this.setSiteConfig(config);
      setCookieObj("site-info", obj);
    }
  }
};
</script>

<style lang="less" scoped>
.index {
  width: 100%;
  height: 100%;
  overflow: auto;
}

.index-content {
  min-width: 1200px;
  height: 100%;
  min-height: 900px;
  background-size: cover;
  background-position: center;
  position: relative;
}
</style>
